<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>canvas绘制圆弧3</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
    </style>
</head>

<body>
    <canvas id="tutorial" width="300" height="300">你的浏览器不支持 canvas，请升级你的浏览器。</canvas>
    <script>
        let canvas = document.getElementById('tutorial');
        //获得 2d 上下文对象
        if (canvas.getContext) {
            let ctx = canvas.getContext('2d');
            ctx.beginPath();
            ctx.moveTo(10, 200); //起始点
            var cp1x = 40, cp1y = 100;  //控制点
            var x = 200, y = 200; // 结束点
            //绘制二次贝塞尔曲线
            ctx.quadraticCurveTo(cp1x, cp1y, x, y);
            ctx.stroke();

            ctx.beginPath();
            ctx.rect(10, 200, 10, 10);
            ctx.rect(cp1x, cp1y, 10, 10);
            ctx.rect(x, y, 10, 10);
            ctx.fill();
        } else {
            console.log("您的浏览器不支持canvas!");
        }
    </script>
</body>

</html>